import winreg

class ExcelPath(object):
    """ Определитель точного пути к excel """
    def __init__(self) -> None:
        pass
    @staticmethod
    def get()->str:
        try:
            aReg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
            aKey = winreg.OpenKeyEx(aReg, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\excel.exe")
            oKey = winreg.QueryValueEx(aKey, "Path")
            if aKey: winreg.CloseKey(aKey)
            return f"{oKey[0]}excel.exe"
        except: raise
        
if __name__=="__main__":
    try:
        ss = ExcelPath.get()
        print(ss)
    except Exception as exp:
        print(exp)